package bjtu.pinet.dto;

import bjtu.pinet.common.ParsingResult;
import bjtu.pinet.utils.IdentifierMapUtils;
import org.onlab.packet.BasePacket;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Host;

import java.io.Serializable;

/**
 * author:chushuai
 * date:2021.2.13
 */
public class DecisionResultObject implements Serializable {
    private static final long serialVersionID = -6193288028931761228L;
    private boolean isSupport;
    private boolean isTurn;
    private ParsingResult.PrincipalsObject decisionPrincipalsObject;
    private int networkTypeId;//表示数据包对应的网络模态类型
    private short etherType;//表示数据包的以太网字段
    private BasePacket packetParsingResult;//表示数据包解析后的各字段的结果
    private ParsingResult.PrincipalsObject principalsObject;//存储网络主体对象
    private String receiceFrom;

    public DecisionResultObject(boolean isSupport,boolean isTurn, ParsingResult.PrincipalsObject decisionPrincipalsObject, int networkTypeId, short etherType, BasePacket packetParsingResult, ParsingResult.PrincipalsObject principalsObject,String receiceFrom) {
        this.isSupport = isSupport;
        this.isTurn = isTurn;
        this.decisionPrincipalsObject = decisionPrincipalsObject;
        this.networkTypeId = networkTypeId;
        this.etherType = etherType;
        this.packetParsingResult = packetParsingResult;
        this.principalsObject = principalsObject;
        this.receiceFrom = receiceFrom;
    }

    public void setSupport(boolean support) {
        isSupport = support;
    }

    public String getReceiceFrom() {
        return receiceFrom;
    }

    public void setReceiceFrom(String receiceFrom) {
        this.receiceFrom = receiceFrom;
    }

    public boolean isSupport() {
        return isSupport;
    }

    public boolean isTurn() {
        return isTurn;
    }

    public void setTurn(boolean turn) {
        isTurn = turn;
    }

    public ParsingResult.PrincipalsObject getDecisionPrincipalsObject() {
        return decisionPrincipalsObject;
    }

    public void setDecisionPrincipalsObject(ParsingResult.PrincipalsObject decisionPrincipalsObject) {
        this.decisionPrincipalsObject = decisionPrincipalsObject;
    }

    public int getNetworkTypeId() {
        return networkTypeId;
    }

    public void setNetworkTypeId(int networkTypeId) {
        this.networkTypeId = networkTypeId;
    }

    public short getEtherType() {
        return etherType;
    }

    public void setEtherType(short etherType) {
        this.etherType = etherType;
    }

    public BasePacket getPacketParsingResult() {
        return packetParsingResult;
    }

    public void setPacketParsingResult(BasePacket packetParsingResult) {
        this.packetParsingResult = packetParsingResult;
    }

    public ParsingResult.PrincipalsObject getPrincipalsObject() {
        return principalsObject;
    }

    public void setPrincipalsObject(ParsingResult.PrincipalsObject principalsObject) {
        this.principalsObject = principalsObject;
    }


    @Override
    public String toString() {
        String turnOrChoose = "";
        String origin = "";
        String isSupportOrNot = "";
        if(isTurn){
            turnOrChoose = "模态切换";
            origin = "切换后";
        }else{
            turnOrChoose = "模态选择";
            origin = "选择的";
        }

        if(isSupport){
            isSupportOrNot = "支持";
        }else{
            isSupportOrNot = "不支持";
        }
        return "模态决策结果:{\n" +
                "管控系统是否支持当前模态:" +isSupportOrNot +"\n"+
                "模态管控模式:" + turnOrChoose +"\n"+
                origin + "网络主体对象:" + decisionPrincipalsObject +"\n"+
                "网络模态类型:" + IdentifierMapUtils.getIdentifierType(networkTypeId) +"\n"+
                "原始以太网类型字段:" + etherType +"\n"+
                "原始数据包解析结果:" + packetParsingResult +"\n"+
                "原始网络主体对象:" + principalsObject + "\n"+
                "接收数据包位置:" + receiceFrom + "\n"+
                '}';
    }
}
